<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title></title>
</head>

<body>
</body>
<script language="JavaScript" type="text/javascript" src="js/jsencrypt.js"></script>

<script type="text/javascript">
    var pubkey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCPhuLKVwg6iyzpwRzkQPDPa3z5w/qwr2S5Nb7TczJZK7pRF5r+Va4h3EKxSn+jBpbmufvJgbpBr4uuJ8U0sPSx3GqoyIUiovbB7SLTKNRxMCfT+O3Qa+cKTqM3269ol8iW6QcmLXwM0nIwy0gLLWqUSPLjnAWJTJsIHDVEYW3rQQIDAQAB";
    var text = "test";
    //java后台生成的
    var encrypt = new JSEncrypt();
    encrypt.setPublicKey(pubkey);
    //加密
    console.log(encrypt.encrypt(text));
</script>

</html>